import java.io.*;
import java.util.Scanner;

public class IO2 {
    //进行文件的复制
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要被拷贝的文件（源文件）：");
        String s1=scanner.next();
        System.out.println("请输入拷贝的文件（目的文件）：");
        String s2=scanner.next();
        File str1=new File(s1);
        if(!str1.isFile()){
            System.out.println("当前输入的源路径地址有误");
            return ;
        }
        File str2=new File(s2);
        if(str2.isFile()){
            System.out.println("当前输入的目标地址有误");
            return;
        }

        try(InputStream inputStream=new FileInputStream(str1);
            OutputStream outputStream=new FileOutputStream(str2)) {
                while(true){
                    int b = inputStream.read();
                    if(b==-1){
                        return;
                    }else{
                        outputStream.write(b);
                    }
                }
            } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
